package com.yjk.controller;


import com.yjk.entity.News;
import com.yjk.service.INewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yjk
 * @since 2022-03-15
 */
@RestController
@RequestMapping("/news")
public class NewsController {
    @Autowired
    private INewsService ns;
    @GetMapping("/")
    public List<News> selectAll(){
        return ns.list();
    }
    @PostMapping("/insert")
    public void insert(String biaoti,String news,String zuozhe,String danwei){
        News news1=new News();
        news1.setBiaoti(biaoti);
        news1.setNews(news);
        news1.setDanwei(danwei);
        news1.setZuozhe(zuozhe);
        ns.save(news1);
    }
}

